<?php
// +----------------------------------------------------------------------
// * Created by PhpStorm.
// +----------------------------------------------------------------------
// * Author: D H
// +----------------------------------------------------------------------
// * Date: 2017/9/4
// +----------------------------------------------------------------------
// * Time: 12:24
// +----------------------------------------------------------------------

namespace app\index\controller;

use think\Request;
use app\api\logic\Merchant as Merchants;
use tool\Common;
use OSS\OssClient;

class Merchant{
    protected  $Merchant;
    public function __construct(Merchants $Merchant)
    {
        $this->Merchant = $Merchant;
    }

    public function upload()
    {
        $package = $this->Merchant->upload();
        Common::json($package);
    }

    //添加商品
    public function addProduct()
    {
        $data = [
            //'sellerID' => '',   //商家ID
           // 'catalogID' => 1,  //分类ID
            'brandName' => '安然' ,    //品牌名称
            'name' => '清水灭火器',          //产品名称
            'model' => 'M2316',        //型号
            'manufacturer' =>'上海力旺消防设备厂',  //制造商
            'origin' => '上海',        //产地
            //'score' => ''          //产品得分
            'class' => 0,           // 类别0国产1进口
            //'specification' => '',    //说明书
            'protocolPrice' => 1986,    //协议价
            'marketsPrice' => 2330,        //市场价
            'addtime' => '',
            'details' =>[
                'xxxxxx.jpg',
                'xxxxxx.jpg',
                'xxxxxx.jpg',
                'xxxxxx.jpg'
            ],                         //商品详情
            'titleImage' => [          //商品展示细节图
                'xxxxxx.jpg',
                'xxxxxx.jpg',
                'xxxxxx.jpg',
                'xxxxxx.jpg'
            ],
            'parameterList' => ''      //产品参数
        ];
        //$data = Request::instance()->post();
        $package = $this->Merchant->init($data)->addProduct();
        Common::json($package);
    }

    //根据分类得到产品参数
    public function geParameterByCatID(){
        $data = Request::instance()->post();
        $package = $this->Merchant->init($data)->geParameterByCatID();
        Common::json($package);
    }

    //根据父类ID的到分类列表
    public function  getCatList(){
        $data = Request::instance()->post();
        $package = $this->Merchant->init($data)->getCatList();
        Common::json($package);
    }
}